﻿<?php

use yii\helpers\Html;
use yii\helpers\Url;
use backend\widgets\GridView;
?>
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <?php echo Html::csrfMetaTags(); ?>
    <link href="<?php echo Yii::$app->homeUrl; ?>css/common/base.css" rel="stylesheet">
    <link href="<?php echo Yii::$app->homeUrl; ?>css/common/common.css" rel="stylesheet">
    <link rel="stylesheet" href="<?php echo Yii::$app->homeUrl; ?>css/common/bootstrap.min.css">
    <link href="<?php echo Yii::$app->homeUrl; ?>css/common/daterangepicker-bs3.css" rel="stylesheet">
    <link href="<?php echo Yii::$app->homeUrl; ?>css/PassList.css" rel="stylesheet">
    <link href="<?php echo Yii::$app->homeUrl; ?>css/ThePass.css" rel="stylesheet">
    <!-- The script --> 
    <script type="text/javascript" src="<?php echo Yii::$app->homeUrl; ?>js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="<?php echo Yii::$app->homeUrl; ?>js/bootstrap.min.js"></script>
    <script type="text/javascript" src="<?php echo Yii::$app->homeUrl; ?>js/extendPagination.js"></script>
    <script type="text/javascript" src="<?php echo Yii::$app->homeUrl; ?>js/moment.js"></script>
    <script type="text/javascript" src="<?php echo Yii::$app->homeUrl; ?>js/daterangepicker.js"></script>
    <?php $this->head() ?>
</head>
<?php $this->beginBody() ?>
<div class="newPass">
    <div class="newPass">
        <h4>
            新建\编辑合作方账号
        </h4>
        <ul>
            <li class="FZ_Tg FZ_new_Tg">
            <o class="tw_title">
                合作方账号
            </o>
            ：
            <input class="form-control" id="username" placeholder="请输入合作方账号" type="text">
            </input>
            </li>
            <li class="FZ_Tg">
            <o class="tw_title">
                合作方名称
            </o>
            ：
            <input class="form-control" id="admin_sn" placeholder="请输入合作方名称" type="text">
            </input>
            </li>
            <li class="FZ_Tg">
            <o class="tw_title">
                密
                <k class="tw_title_MM">
                    密码
                </k>
                码
            </o>
            ：
            <input class="form-control" id="password" placeholder="请输入密密" type="text">
            </input>
            </li>
            <li class="FZ_Tg">
            <o class="tw_title">
                重复密码
            </o>
            ：
            <input class="form-control" id="repassword" placeholder="请输入重复密码" type="text">
            </input>
            </li>
            <li class="FZ_Tg BZ">
            <o class="tw_title">
                账号 备注
            </o>
            ：
            <div>
                <textarea class="comments" id ="remark" cols="27" maxlength="200" name="comments" rows="1">
                </textarea>
                <span>
                    限50字
                </span>
            </div>
            </li>
            <li class="lassLI ">
                <button class="btn btn-primary tw_QDOK" type="button">
                    保存创建
                </button>
                <button class="btn btn-primary tw_QX" type="button">
                    取消
                </button>
            </li>
        </ul>
    </div>
    <div class="bottom">
    </div>
    <div class="bottom">
    </div>
    <?php $this->endBody() ?>
<script>
    $(".tw_QX").click(function () {
        window.history.back(-1);
    });
    $(".tw_QDOK").click(function () {
        var username = $("#username").val(); 
        if(username == ''){
            alert('合作方账号不能为空');
            return false;
        }
        var admin_sn = $('#admin_sn').val();
        if(admin_sn == ''){
            alert('合作方名称不能为空');
            return false;
        }
        var password = $("#password").val(); 
        if(password == ''){
            alert('密码不能为空');
            return false;
        }
        var repassword = $('#repassword').val();
        if(repassword == ''){
            alert('重复密码不能为空');
            return false;
        }
        if(password != repassword ){
            alert('俩次输入密码不正确，请重新输入');
            return false;
        }
        var remark = $('#remark').val();
        $.ajax({
            url: "/admin/create",
            type: "post",
            dataType: "json",
            data: {
                username: username,
                admin_sn: admin_sn,
                password: password,
                repassword: repassword,
                remark: remark,
            },
            success: function (data) {
                if(data.code == 0){
                    alert(data.msg);
                }else{
                    alert(data.msg);
                }
            },
            error: function() {
                alert('网络错误！');
                location.href="/admin/create"
            }
        });
    });

</script>